import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class mz01 {
    public static void main(String[] args) {

    play2 p2=new play2();
        ExecutorService pool1 =  Executors.newFixedThreadPool(5);
        for(int a1=0;a1<5;a1++){
            pool1.execute(p2);
        }
//    play1 p=new play1();
//        ExecutorService pool =  Executors.newFixedThreadPool(5);
//            for(int a1=0;a1<5;a1++){
//                pool.execute(p);
//            }
 }
}
class play1 extends Thread{
    private int a=20;
    @Override
    public void run() {
        while(true){
            synchronized (play1.class){
            if(a>0){
                try {
                    Thread.sleep(5);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(Thread.currentThread().getName()+"="+a--);
            } else break;
        }
        }
    }
}
class play2 implements Runnable{
private  int b=50;
    @Override
    public void run() {
        while(true){
            synchronized (play2.class){
                if(b>0){
                    try {
                        Thread.sleep(5);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println(Thread.currentThread().getName()+"="+b--);
                }else {
                    break;
                }
            }
        }

    }
}
